import axios from "axios";

export function request(config) {
  //1.创建axios实例
  const instance = axios.create({
    // baseURL: "https://dqb-1688.com:8000/",
    baseURL: "http://114.132.236.89:8081",
    timeout: 0
  });

  //2.axios的拦截
  //2.1请求拦截
  instance.interceptors.request.use(
    (config) => {
      console.log("@@@@",config);
      // config.headers.Authorization = window.localStorage.getItem('token')
      return config;
    },
    (err) => {
      console.log("@@",err);
    }
  );

  //2.2响应拦截
  instance.interceptors.response.use(
    (res) => {
      return res.data;
    },
    (err) => {
      console.log(err);
    }
  );

  //3.发送网络请求
  return instance(config);
}
